package com.reform.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @description  跨域配置
 * @author mortale
 * @since 2021/6/28 13:53
 *
 */
@Configuration
public class CORSConfig implements  WebMvcConfigurer {


    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") // 设置访问接口地址
                .allowedOrigins("http://localhost:8081","http://www.sugao.fun","https://www.sugao.fun") //设置访问源地址
                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE") // 设置请求方法
                .maxAge(3600) // 最大时间
                .allowCredentials(true); //是否允许
    }

}
